<?php
/**
 * This file is part of workerman.
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the MIT-LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @author walkor<walkor@workerman.net>
 * @copyright walkor<walkor@workerman.net>
 * @link http://www.workerman.net/
 * @license http://www.opensource.org/licenses/mit-license.php MIT License
 */

/**
 * 用于检测业务代码死循环或者长时间阻塞等问题
 * 如果发现业务卡死，可以将下面declare打开（去掉//注释），并执行php start.php reload
 * 然后观察一段时间workerman.log看是否有process_timeout异常
 */
declare(ticks=1);

/**
 * 主逻辑
 * 主要是处理 onMessage onClose 
 */
use \GatewayWorker\Lib\Gateway;
use \Workerman\Lib\Timer;
require_once __DIR__.'/../vendor/autoload.php';
class Events
{

    //开始启动之后
    public static function onWorkerStart()
    {   
          Timer::add(3, function(){
         
          }); 
    }

    //连接之后
    public static function  onConnect($client_id){
          $data=["cliet"=>$client_id,"type"=>1];
          Gateway::sendToCurrentClient(json_encode($data));
    }

   /**
    * 有消息时
    * @param int $client_id
    * @param mixed $message
    */
   public static function onMessage($client_id, $message)
   {
        
        return ;
   }
   
   /**
    * 当客户端断开连接时
    * @param integer $client_id 客户端id
    */
   public static function onClose($client_id)
   {
        // $json =
        //  Gateway::sendToAll($client_id);
        //  return ;
   }

}
